#ifndef MALLET_H
#define MALLET_H

#include <QVector4D>
#include "circle3d.h"
#include "cylinder3d.h"
#include "object_builder.h"
#include "geometry/single_color_object.h"

class Mallet : public SingleColorObject {

    public:
        Mallet(float radius, float height, int numPoints);
        virtual ~Mallet() {
            delete m_baseCircle;
            delete m_baseCylinder;
            delete m_handleCircle;
            delete m_handleCylinder;
        };

        inline const float *getVertexData() override {
            return m_vertexData;
        };
        inline size_t getVertexPointSize() override {
            return (openCylinderVertexSize(m_numPoints) + circleVertexSize(m_numPoints)) * 2;
        };
        inline int getNumPoints() {
            return m_numPoints;
        };
        inline float getHeight() {
            return m_height;
        };
        inline int getCirclePointSize() {
            return circleVertexSize(m_numPoints);
        };
        inline int getCylinderPointSize() {
            return openCylinderVertexSize(m_numPoints);
        };
        inline int getBaseCylinderPointStart() {
            return 0;
        };
        inline int getBaseCirclePointStart() {
            return getBaseCylinderPointStart() + openCylinderVertexSize(m_numPoints);
        };
        inline int getHandleCylinderPointStart() {
            return getBaseCirclePointStart() + circleVertexSize(m_numPoints);
        };
        inline int getHandleCirclePointStart() {
            return getHandleCylinderPointStart() + openCylinderVertexSize(m_numPoints);
        };
        inline void setColor (float r, float g, float b, float opacity = 1.0f) {
            m_color.setX(r);
            m_color.setY(g);
            m_color.setZ(b);
            m_color.setW(opacity);
            m_circleColor = m_color * 0.8f;
            m_cylinderColor = m_color * 0.5f;
        };
        inline QVector4D &getCircleColor() {
            return m_circleColor;
        };
        inline QVector4D &getCylinderColor() {
            return m_cylinderColor;
        };

    private:
        void debugCircleData(int start, int numPoints);

    private:
        QVector4D m_color, m_circleColor, m_cylinderColor;
        float m_radius, m_height;
        int m_numPoints;
        Circle3D *m_baseCircle = nullptr;
        Cylinder3D *m_baseCylinder = nullptr;
        Circle3D *m_handleCircle = nullptr;
        Cylinder3D *m_handleCylinder = nullptr;
};

#endif // MALLET_H
